00001 /////////////////////////////////////////////////////////////////////////////// 00002 /// @file deWorld.hpp 00003 /// 00004 /// @brief Destiny "World" storage 00005 /// 00006 /// @author Assassin 00007 /// 00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the 00009 /// contents of this file is subject to the Destiny3D Member License which 00010 /// can be found at http://www.destiny3d.com. Any other usage is prohibited. 00011 /// 00012 /// This file is distributed "AS IS" without warranty of any kind. Novus 00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file 00014 /// for any particular purpose. 00015 /// 00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved. 00017 /// 00018 /// <hr> 00019 /// Change History 00020 /// <hr> 00021 /// 00022 /// @date Dec 2001 00023 /// @author Assassin 00024 /// @remarks Creation 00025 /// 00026 /// @date Feb 2002 00027 /// @author Assassin 00028 /// @remarks Rendering functionality moved to deRender 00029 /// 00030 /// @date Sep 2002 00031 /// @author Assassin 00032 /// @remarks Tear-down and re-write 00033 /// 00034 /////////////////////////////////////////////////////////////////////////////// 00035 00036 #ifndef DEWORLD_HPP 00037 #define DEWORLD_HPP 00038 00039 #include "deGlobalTypes.hpp" 00040 #include "deArray.hpp" 00041 #include "deResource.hpp" 00042 00043 #if defined(DEWORLD_DLL_EXPORTS) || defined(DESTINY3D_EXPORT_ALL) 00044 # define DEWORLD_API extern "C" DEDLL_EXPORT 00045 #elif defined(DESTINY3D_STATIC_LINK) 00046 # define DEWORLD_API extern "C" 00047 #else 00048 # define DEWORLD_API extern "C" DEDLL_IMPORT 00049 #endif 00050 00051 #ifdef USING_DESTINY3D 00052 #ifdef _DEBUG 00053 # ifdef DESTINY3D_STATIC_LINK 00054 # pragma comment(lib, "deWorld_sd") 00055 # else 00056 # pragma comment(lib, "deWorldd") 00057 # endif //DESTINY3D_STATIC_LINK 00058 #else 00059 # ifdef DESTINY3D_STATIC_LINK 00060 # pragma comment(lib, "deWorld_s") 00061 # else 00062 # pragma comment(lib, "deWorld") 00063 # endif //DESTINY3D_STATIC_LINK 00064 #endif //_DEBUG 00065 #endif //USING_DESTINY3D 00066 00067 class IdeFile; 00068 class IdeWorld; 00069 class IdeWorldManager; 00070 class IdeWorldObject; 00071 00072 /// Exported function for retrieving a pointer to the deWorldManager singleton 00073 DEWORLD_API IdeWorldManager* IdeWorld_GetManager(); 00074 DEWORLD_API void IdeWorld_ShutDown(); 00075 00076 typedef IdeWorldManager* (*fIdeWorld_GetManager)(); 00077 typedef IdeWorldObject* (*IdeWorldObject_Creator)(); 00078 00079 /// Manager for various deWorld duties 00080 //class IdeWorldManager 00081 DE3D_INTERFACE_(IdeWorldManager) 00082 { 00083 protected: 00084 ~IdeWorldManager() {} 00085 public: 00086 /// create a world that can then be used to store data 00087 virtual deWorldID CreateWorld() = 0; 00088 /// retrieve a created world 00089 virtual IdeWorld* GetWorld(deWorldID ID) = 0; 00090 /// retrieve a world object without need for retrieving the world pointer 00091 virtual IdeWorldObject* GetWorldObject(deWorldID WID, deObjectID OID) = 0; 00092 /// get the deResource interface ID for deWorld 00093 virtual long GetRscInterfaceID() = 0; 00094 /// obtain a unique ID to use when using classes derived from deWorldObject 00095 virtual long GetUniqueWOInterfaceID() = 0; 00096 /// register a WorldObject class, which can then be loaded by string identifier 00097 virtual deBoolean RegisterWOClass(const char* ClassName, IdeWorldObject_Creator creator) = 0; 00098 }; 00099 00100 /// IdeWorld is the basic interface to the deWorld storage class 00101 //class IdeWorld : virtual public IdeResourceBase 00102 DE3D_INTERFACE(IdeWorld, IdeResourceBase) 00103 { 00104 protected: 00105 virtual ~IdeWorld(void) {} 00106 public: 00107 /// Get the ID number of this world 00108 virtual deWorldID GetWorldID() = 0; 00109 /// Used by descendants of IdeWorldObject so that they can store a "local" world ID 00110 /// which is serializable, using a translation layer. Reverses GetLocalIDFromLoadedWorld output 00111 virtual deWorldID GetWorldIDUsingLocalID(deWorldID LocalID, deBoolean ForceLoad = deFALSE) = 0; 00112 /// translates the ID of a currently loaded deWorld into a "local" world ID that 00113 /// world objects can serialize safely. 00114 virtual deWorldID GetLocalIDFromLoadedWorld(deWorldID WorldID) = 0; 00115 /// Get the interface to an object based on its ID 00116 virtual IdeWorldObject* GetWorldObject(deObjectID ObjectID) = 0; 00117 00118 /// Write the world to an open file 00119 virtual deBoolean Serialize(IdeFile* File) = 0; 00120 /// Read the world from an open file 00121 virtual deBoolean DeSerialize(IdeFile* File) = 0; 00122 00123 /// Call repeatedly to retrieve the typenames of all the stored items 00124 /// @return pointer to character array containing name of a type 00125 /// @param PrevEntry a void pointer that is modified inside the function. Set to NULL for the first call. 00126 virtual const char* GetNextObjectTypeName(void* &PrevEntry) = 0; 00127 /// Call repeatedly to retrieve the stored objects 00128 /// @return the ID of an object stored in this world with the type name specified 00129 /// @param TypeName a string indicating the typename of an object. Use return value of GetNextObjectTypeName. 00130 /// @param PrevEntry a void pointer that is modified inside the function. Set to NULL for the first call. 00131 virtual deObjectID GetNextObjectOfType(const char* TypeName, void* &PrevEntry) = 0; 00132 00133 // following methods for internal use only 00134 // obtain a unique item ID to use within this world 00135 virtual deObjectID AddWorldObject(IdeWorldObject * Object) = 0; 00136 virtual deBoolean AddWorldObjectWithID(IdeWorldObject * Object) = 0; 00137 virtual deBoolean RemoveWorldObject(deObjectID ObjectID) = 0; 00138 }; 00139 00140 /// IdeWorldObject is the abstract base for a deWorld to talk to its objects 00141 //class IdeWorldObject : virtual public IdeRefCountBase 00142 DE3D_INTERFACE(IdeWorldObject, IdeRefCountBase) 00143 { 00144 protected: 00145 virtual ~IdeWorldObject() {} 00146 public: 00147 /// request a related interface, identified with an ID originally returned from 00148 /// IdeWorldManager::GetUniqueWOInterfaceID 00149 virtual void* GetWOInterface(long interface_id) = 0; 00150 /// retrieve the specific type name of the object 00151 virtual const char* GetWOTypeName() = 0; 00152 00153 /// Retrieve the object's world-unique object ID 00154 virtual deObjectID GetObjectID() = 0; 00155 /// Retrieve the object's runtime-unique World ID 00156 virtual deWorldID GetWorldID() = 0; 00157 00158 /// Set the object's world ID to a specified World ID. 00159 /// @param WorldID 0 or a valid ID for a currently loaded deWorld 00160 /// @param ObjectID Reserved use - Use 0 (default) 00161 virtual deBoolean SetWorldID(deWorldID WorldID, deObjectID ObjectID = 0) = 0; 00162 00163 /// Set a private data member for this object, along with its size in bytes. 00164 /// This data is serialized, so don't store any pointer data. 00165 /// The data is copied into an internally-allocated area, so you can feed local variables in. 00166 /// Calling with 'pData = NULL' will cause it to destroy the data. 00167 virtual deBoolean SetPrivateData(void* pData, long Size) = 0; 00168 /// Retrieve the private data member for this object, along with its size in bytes. 00169 virtual void* GetPrivateData(long & pSize) = 0; 00170 00171 /// Serialize the object into an open IdeFile - used by deWorld internally 00172 virtual deBoolean Serialize(IdeFile* File) = 0; 00173 /// De-Serialize the object from an open IdeFile - used by deWorld internally 00174 virtual deBoolean DeSerialize(IdeFile* File, long DataLength) = 0; 00175 /// Call after all objects in a world have been loaded, to allow pointers to be correctly 00176 /// resolved from World and Object ID's 00177 virtual deBoolean DeSerializeLoad() = 0; 00178 }; 00179 00180 #endif
1.3-rc3